package com.etong.citymap.util;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.provider.Settings;
import android.widget.Toast;

public class GPSCtrol {
	Activity activity;
	private boolean isOpen;
	public GPSCtrol(Activity activity) {
		this.activity = activity;
	}

	public void openGPSSettings() {
		LocationManager alm = (LocationManager) activity
				.getSystemService(Context.LOCATION_SERVICE);
		if (alm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
			setOpen(true);
			return ;
		}
		setOpen(false);
		Toast.makeText(activity, "请开启GPS！", Toast.LENGTH_SHORT).show();
		Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
		activity.startActivityForResult(intent, 0); // 此为设置完成后返回到获取界面
	}

	public boolean isOpen() {
		return isOpen;
	}

	public void setOpen(boolean isOpen) {
		this.isOpen = isOpen;
	}
}
